package sc
{
	import flash.events.*;
	import flash.filesystem.*;
	
	import mx.events.*;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.controls.Alert;
	public class Export
	{
		public static var ext:String = ".html";
		public static var path:String = "/";
		
		public function Export()
		{
			//TODO: implement function
		}
		public static function useTemplate(body:String, templ:String, title:String = 'untitled', nav:String = '', root:String = '/'):String {
			templ = templ.replace(/%%title%%/g, title);
			templ = templ.replace(/%%navigation%%/g, nav);
			templ = templ.replace(/%%body%%/g, body);
			templ = templ.replace(/%%path%%/g, root);
			return templ;
		}
		
		public static function doit(result:ResultEvent):void {
			//tabCont.selectedChild.setHtml(result.result.toString());
			var hell:texy_editor_tab = $.main.tabCont.selectedChild as  texy_editor_tab;
			var col:XML = result.result as XML;
			hell.clearResultTabs();
			
			for each (var d:XML in col.doc) {
				var data:Object = { content:d.cont, title:d.title, navigation:col.navigation, url:d.url };
				hell.resultTab(d.cont, d.title, data);
			}
			hell.prog.visible = false;
			hell.sub.enabled = true;
			//trace(result.result.toString());
		}
		
		public static function onFault(event:FaultEvent):void {
			Alert.show("There was an error connecting to the app's processing server. Please check your connection and try again.", "Connection error", Alert.OK);
			var hell:texy_editor_tab = $.main.tabCont.selectedChild as  texy_editor_tab;
			hell.prog.visible = false;
			hell.sub.enabled = true;
		}
		
			
			
			

	}
}